package com.openvas.controller;

import java.util.List;
//    import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.openvas.commons.common.annotation.Log;
import com.openvas.commons.common.enums.BusinessType;
import com.openvas.domain.TableOperatingSystem;
import com.openvas.service.ITableOperatingSystemService;
import com.openvas.commons.common.core.controller.BaseController;
import com.openvas.commons.common.core.domain.AjaxResult;

import com.openvas.commons.common.core.page.TableDataInfo;

/**
 * 操作系统Controller
 * 
 * @author ruoyi
 * @date 2021-11-04
 */
@Controller
@RequestMapping("/api/system")
public class TableOperatingSystemController extends BaseController
{
    private String prefix = "system/system";

    @Autowired
    private ITableOperatingSystemService tableOperatingSystemService;

   // //  @RequiresPermissions("system:system:view")
    @GetMapping()
    public String system()
    {
        return prefix + "/system";
    }

    /**
     * 查询操作系统列表
     */
   // //  @RequiresPermissions("system:system:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TableOperatingSystem tableOperatingSystem)
    {
        startPage();
        List<TableOperatingSystem> list = tableOperatingSystemService.selectTableOperatingSystemList(tableOperatingSystem);
        return getDataTable(list);
    }

    /**
     * 导出操作系统列表
     */
   // //  @RequiresPermissions("system:system:export")
    @Log(title = "操作系统", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TableOperatingSystem tableOperatingSystem)
    {
        List<TableOperatingSystem> list = tableOperatingSystemService.selectTableOperatingSystemList(tableOperatingSystem);
//        ExcelUtil<TableOperatingSystem> util = new ExcelUtil<TableOperatingSystem>(TableOperatingSystem.class);
//        return util.exportExcel(list, "操作系统数据");
        return null;
    }

    /**
     * 新增操作系统
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存操作系统
     */
   // //  @RequiresPermissions("system:system:add")
    @Log(title = "操作系统", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TableOperatingSystem tableOperatingSystem)
    {
        return toAjax(tableOperatingSystemService.insertTableOperatingSystem(tableOperatingSystem));
    }

    /**
     * 修改操作系统
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TableOperatingSystem tableOperatingSystem = tableOperatingSystemService.selectTableOperatingSystemById(id);
        mmap.put("tableOperatingSystem", tableOperatingSystem);
        return prefix + "/edit";
    }

    /**
     * 修改保存操作系统
     */
   // //  @RequiresPermissions("system:system:edit")
    @Log(title = "操作系统", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TableOperatingSystem tableOperatingSystem)
    {
        return toAjax(tableOperatingSystemService.updateTableOperatingSystem(tableOperatingSystem));
    }

    /**
     * 删除操作系统
     */
   // //  @RequiresPermissions("system:system:remove")
    @Log(title = "操作系统", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tableOperatingSystemService.deleteTableOperatingSystemByIds(ids));
    }
}
